import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

/**
 *
 * @author Bora SAYINER
 * @since Dec 6, 2014 12:37:28 PM
 * @version 1.0
 */
public class Driver {

	private static final int SIZE = 150;

	public static void main(String[] args) {
		// ArrayList numbers = new ArrayList();
		// numbers.add(5);
		// numbers.add(10);
		// numbers.add(12);
		// numbers.add(15);
		// numbers.add(23);
		// numbers.add(3);
		// numbers.add(-99);
		// System.out.println(numbers.get(2));
		// // numbers.remove(2);
		// System.out.println(numbers.get(2));
		// int indexOf = numbers.indexOf(15);
		// System.out.println(indexOf);
		// numbers.add(3, 33);
		//
		// System.out.println(numbers.size());
		// System.out.println(numbers.contains(325));
		// Object[] array = numbers.toArray();
		// numbers.sort(new Comparator() {
		//
		// @Override
		// public int compare(Object o1, Object o2) {
		// int sayi1 = (int) o1;
		// int sayi2 = (int) o2;
		// int result = 0;
		// if (sayi1 > sayi2) {
		// result =1;
		// } else if (sayi1 < sayi2) {
		// result = -1;
		// }
		// return result;
		// }
		// });
		// System.out.println("------------------------");
		// for (Object object : numbers) {
		// System.out.println(object);
		// }

		// ArrayList employees = new ArrayList();
		// employees.add(new Employee(1, "Önder", "ŞAHİN", 2500));
		// employees.add(new Employee(2, "Emre", "ÇELEBİ", 3200));
		// employees.add(new Employee(3, "Koray", "ALTINDAŞ", 1200));
		//
		// System.out.println("Before");
		//
		// for (int i = 0; i < employees.size(); i++) {
		// System.out.println(employees.get(i));
		// }
		//
		// employees.sort(new Driver().new EmployeeComparator());
		//
		// System.out.println("After");
		//
		// for (int i = 0; i < employees.size(); i++) {
		// System.out.println(employees.get(i));
		// }

		// MyArray myArray = new MyArray();
		// for (int i = 0; i < SIZE; i++) {
		// myArray.add(i);
		// }
		// for (int i = 0; i < SIZE; i++) {
		// System.out.println(myArray.get(i));
		// }

		ArrayList sayilar = new ArrayList();
		while (true) {
			Scanner scanner = new Scanner(System.in);
			System.out.print("Sayi giriniz: ");
			String userInput = scanner.nextLine();
			if (userInput.equalsIgnoreCase("q")) {
				break;
			} else {
				sayilar.add(Integer.parseInt(userInput));
			}
		}
		float total = 0;
		for (int i = 0; i < sayilar.size(); i++) {
			total += (int) sayilar.get(i);
		}
		System.out.println("Ortalama : " + (total / sayilar.size()));
	}

	public class EmployeeComparator implements Comparator {

		@Override
		public int compare(Object o1, Object o2) {
			Employee employee1 = (Employee) o1;
			Employee employee2 = (Employee) o2;
			int result = 0;
			if (employee1.getSalary() > employee2.getSalary()) {
				result = -1;
			} else if (employee1.getSalary() < employee2.getSalary()) {
				result = 1;
			}
			return result;
		}

	}

}
